package com.tencent.trtc.apiexample;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.tencent.trtc.apiexample.ui.notifications.NotificationsFragment;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

public class NavActivity extends AppCompatActivity {
    private String result = "";
    private String updateResult="";
    private String createResult="";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nav);
        BottomNavigationView navView = findViewById(R.id.nav_view);
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_nav);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);
        Intent intent = getIntent();
        result = intent.getStringExtra("result");
        createResult=intent.getStringExtra("createinf");
        updateResult = intent.getStringExtra("upresult");
        if(result != null) {
            if (result.equals("0")) {
                Toast.makeText(NavActivity.this, "密码错误，请检查后重新输入！", Toast.LENGTH_LONG).show();
            } else if (result.equals("1")) {
                Toast.makeText(NavActivity.this, "修改密码成功！", Toast.LENGTH_LONG).show();
            } else if (result.equals("2")) {
                Toast.makeText(NavActivity.this, "数据库错误！请联系开发者！", Toast.LENGTH_LONG);
            } else {
                Toast.makeText(NavActivity.this, "程序出现错误！", Toast.LENGTH_LONG);
            }
        }

        if(updateResult != null){
            if(updateResult.equals("1")){
                Toast.makeText(NavActivity.this, "修改资料成功！", Toast.LENGTH_LONG).show();
            }else{
                Toast.makeText(NavActivity.this, "修改资料失败，请重试！", Toast.LENGTH_LONG).show();
            }
        }

        if(createResult !=null){
            if(!createResult.equals("0")){
                Toast.makeText(NavActivity.this, "创建房间成功!", Toast.LENGTH_LONG).show();
            }
            else{
                Toast.makeText(NavActivity.this, "创建房间失败，请重试！", Toast.LENGTH_LONG).show();
            }
        }

    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {

        super.onActivityResult(requestCode, resultCode, data);
    }
}
